package cn.ltgodm.moj.controller;

import cn.ltgodm.moj.common.ErrorCode;
import cn.ltgodm.moj.constant.UserConstant;
import cn.ltgodm.moj.exception.BusinessException;
import cn.ltgodm.moj.model.entity.User;
import cn.ltgodm.moj.model.enums.UserRoleEnum;
import cn.ltgodm.moj.model.vo.LoginUserVO;
import cn.ltgodm.moj.model.vo.UserVO;
import cn.ltgodm.moj.service.UserFeignClient;
import cn.ltgodm.moj.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.List;

/**
 * @author ltgodm
 * @date 2024-03-13 22:34:46
 * 服务内部互相调用的接口
 */
@RestController()
@RequestMapping("/inner")
public class UserInnerController implements UserFeignClient {

    @Resource
    UserService userService;

    /**
     * 根据id获取用户
     *
     * @param userId
     * @return
     */
    @GetMapping("/get/id")
    public User getById(@RequestParam("userId") Long userId) {
        return userService.getById(userId);
    }

    /**
     * 根据id列表获取用户列表
     *
     * @param idList
     * @return
     */
    @GetMapping("/get/ids")
    public List<User> listByIds(@RequestParam("idList") Collection<Long> idList) {
        return userService.listByIds(idList);
    }


}
